package com.fc.v2.service;

import com.fc.v2.common.base.BaseService;
import com.fc.v2.mapper.auto.SysUserMapper;
import com.fc.v2.mapper.auto.TSysRoleUserMapper;
import com.fc.v2.mapper.auto.TsysUserMapper;
import com.fc.v2.model.auto.TSysRoleUser;
import com.fc.v2.model.auto.TSysRoleUserExample;
import com.fc.v2.model.auto.TsysUser;
import com.fc.v2.model.auto.TsysUserExample;
import com.fc.v2.shiro.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import java.util.ArrayList;
import java.util.List;

/**
 * 专家信息完善
 * 在启动项目时，检测专家的银行卡号和开户行是否已完善，没有完善则要求先完善才能操作
 */
@Service
public class ExpertInfoService implements BaseService<TsysUser, TsysUserExample> {


    @Autowired
    private TSysRoleUserMapper tSysRoleUserMapper;

    @Autowired
    private TsysUserMapper tsysUserMapper;

    public String editInfo(){
        //判断当前用户是否为专家
        TSysRoleUserExample example = new TSysRoleUserExample();
        example.createCriteria().andSysUserIdEqualTo(ShiroUtils.getUserId());
        List<TSysRoleUser> ruList = new ArrayList<>();
        ruList = tSysRoleUserMapper.selectByExample(example);
        //判断银行卡号和支行是否填写
        String flag = "";
        if(ruList.get(0).getSysRoleId().equals("615413901659607040")){
            TsysUser tsysUser = tsysUserMapper.selectByPrimaryKey(ShiroUtils.getUserId());
            if(tsysUser.getUserBankCard() == null || tsysUser.getUserBankCard().equals("") ||tsysUser.getUserBankAddress() == null || tsysUser.getUserBankAddress().equals("")){
                flag = "y";
            }
        }else {
            flag = "n";
        }
        return flag;
    }

    @Override
    public int deleteByPrimaryKey(String id) {
        return 0;
    }

    @Override
    public int insertSelective(TsysUser record) {
        return 0;
    }

    @Override
    public TsysUser selectByPrimaryKey(String id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(TsysUser record) {
        return 0;
    }

    @Override
    public int updateByExampleSelective(TsysUser record, TsysUserExample example) {
        return 0;
    }

    @Override
    public int updateByExample(TsysUser record, TsysUserExample example) {
        return 0;
    }

    @Override
    public List<TsysUser> selectByExample(TsysUserExample example) {
        return null;
    }

    @Override
    public long countByExample(TsysUserExample example) {
        return 0;
    }

    @Override
    public int deleteByExample(TsysUserExample example) {
        return 0;
    }


}
